using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace ReminderApp
{
    public enum PopupMethod {Image = 1, Clip = 2, Text = 3};

    public class ReminderAction
    {
        private Timer myTimer;

        public Timer MyTimer
        {
            get { return myTimer; }
            set { myTimer = value; }
        }
	
        public string GetShowedValue()
        {
            string XmlFilePath = "Reminder.config";

            XmlDocument LoadXmlDoc = new XmlDocument();
            LoadXmlDoc.Load(XmlFilePath);

            XmlNodeList node = LoadXmlDoc.GetElementsByTagName("ShowedValue");

            return node.Item(0).InnerText;
        }

        public void GetTimeScale(out string from, out string to, out string interval, out bool startWithWindow)
        {
            string XmlFilePath = "Reminder.config";

            XmlDocument LoadXmlDoc = new XmlDocument();
            LoadXmlDoc.Load(XmlFilePath);

            XmlNodeList intervalNode = LoadXmlDoc.GetElementsByTagName("Interval");
            interval = intervalNode.Item(0).InnerText;

            XmlNodeList fromNode = LoadXmlDoc.GetElementsByTagName("FromTime");
            from = fromNode.Item(0).InnerText;

            XmlNodeList toNode = LoadXmlDoc.GetElementsByTagName("ToTime");
            to = toNode.Item(0).InnerText;

            XmlNodeList startWithWindowNode = LoadXmlDoc.GetElementsByTagName("StartWithWindow");
            startWithWindow = bool.Parse(startWithWindowNode.Item(0).InnerText);
        }

        public void SaveShowedValue(string showedValue)
        {
            string XmlFilePath = "Reminder.config";

            XmlDocument LoadXmlDoc = new XmlDocument();
            LoadXmlDoc.Load(XmlFilePath);

            XmlNodeList node = LoadXmlDoc.GetElementsByTagName("ShowedValue");
            node.Item(0).InnerText = showedValue;
            LoadXmlDoc.Save("Reminder.config");
        }

        public void SaveTimeScale(string from, string to, string interval)
        {
            string XmlFilePath = "Reminder.config";

            XmlDocument LoadXmlDoc = new XmlDocument();
            LoadXmlDoc.Load(XmlFilePath);

            XmlNodeList intervalNode = LoadXmlDoc.GetElementsByTagName("Interval");
            intervalNode.Item(0).InnerText = interval;

            XmlNodeList fromNode = LoadXmlDoc.GetElementsByTagName("FromTime");
            fromNode.Item(0).InnerText = from;

            XmlNodeList toNode = LoadXmlDoc.GetElementsByTagName("ToTime");
            toNode.Item(0).InnerText = to;

            LoadXmlDoc.Save("Reminder.config");
        }

        public void ShowTextMessage()
        {
            MessageBox.Show(GetShowedValue());
        }
    }
}
